package cn.ryh.jpa.service.impl;

import cn.ryh.jpa.dao.UserDao;
import cn.ryh.jpa.entity.User;
import cn.ryh.jpa.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @ClassName UserServiceImpl
 * @Description User服务类
 * @Author RaoYH
 * @Date 2018/10/30 17:27
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;
    @Override
    @Transactional(readOnly = false)
    public User findUserById(Integer id) {
        Optional<User> user = userDao.findById(id);
        return user.orElse(null);
    }
}
